function handles = moveGroupUpDown(handles, direction)
% moveGroupUpDown
%
% Editing:
% gs may 2005
% ---------------------------------------------------

% determine which group to move
oldVal = get(handles.groupList, 'Value');

% which direction, if at all
maxVal = max(size(get(handles.groupList, 'String')));
switch direction
    case 'up'
        if oldVal == 1
            return
        else
            newVal = oldVal - 1;
        end
    case 'down'
        if oldVal == maxVal;
            return
        else
            newVal = oldVal + 1;
        end
    otherwise
end

% rename as needed in the handles structure
listsAndExpts = handles.analysis.mapAverager.cellLists.currentFile.listsAndExpts;
listsAndExptsNew = listsAndExpts;
listsAndExptsNew{newVal,1} = listsAndExpts{oldVal,1};
listsAndExptsNew{oldVal,1} = listsAndExpts{newVal,1};
listsAndExptsNew{newVal,2} = listsAndExpts{oldVal,2};
listsAndExptsNew{oldVal,2} = listsAndExpts{newVal,2};
handles.analysis.mapAverager.cellLists.currentFile.listsAndExpts = listsAndExptsNew;

% update the listboxes
set(handles.groupList, 'String', listsAndExptsNew(:,1));
set(handles.groupList, 'Value', newVal);
handles = updateLists(handles);

% save
handles = saveListFile(handles);
